<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016-04-25
 * Time: 15:01
 */

use yii\helpers\Url;

$web = Url::to("@web");
?>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1, maximum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <title>我的订单</title>

    <link type="text/css" href="<?= $web ?>/css/wx-good/global.css" rel="stylesheet"/>
    <link type="text/css" href="<?= $web ?>/css/wx-good/order-list.css" rel="stylesheet"/>

    <script type="text/javascript" src="<?= $web ?>/js/jquery.js"></script>
    <script type="text/javascript" src="<?= $web ?>/js/tools.js"></script>
    <?php     require_once Yii::$app->viewPath.'/wx-no-share.php'  ?>
    <script type="application/javascript">
        $(document).ready(function () {
            var w = $(document).width();
            if (w > 640) {
                w = 640;
            }
            $("html").css("font-size", w * 20 / 320);

            loadList();

            $(document).scroll(function () {
                var windowsHeight = $(window).height();
                var scrollTop = $(document).scrollTop();
                var documentHeight = $(document).height();
                if (scrollTop + windowsHeight >= documentHeight) {
                    loadList();
                }
            });
        });

        function redirectorderDetail(orderId) {
            window.location.href = "<?= Url::to('order-detail') ?>?order_id=" + orderId;
        }

        var page = 0;
        var pageSize = 5;
        var isLoading = false;
        var isLoadAllComplated = false;
        function loadList() {
            if (isLoadAllComplated == true) {
                return;
            }

            if (isLoading == true) {
                return;
            }

            isLoading = true;

            var data = {};
            data.page = page;
            data.pageSize = pageSize;

            $(".loading-more").show();
            $.ajax({
                async: true,
                type: "POST",
                url: "<?=Url::to(['wx-good/order-list-order-part-view'])?>" + '?t=' + jst,
                data: data,
                dataType: 'html',
                success: function (html, textStatus) {
                    if (textStatus == 'success') {
                        if ($.trim(html).length > 0) {
                            $("#list_container").append(html);
                            page++;
                        } else {
                            isLoadAllComplated = true;

                        }
                    }
                    $(".loading-more").hide();
                    isLoading = false;
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    isLoading = false;
                }
            });
        }

        function searchOrderLogistics(order_id) {
            window.location.href = '<?=Url::to(["wx-good/order-logistics"])?>' + '?order_id=' + order_id;
        }
    </script>
</head>
<body>
<div class="main">
    <div id="list_container"></div>
    <div class="loading-more">正在加载数据....</div>
</div>
</body>
</html>
